package com.example.smsservice;


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.net.MalformedURLException;
import java.net.URL;
import java.net.UnknownHostException;

import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
import org.xml.sax.InputSource;

import android.R.layout;
import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.location.LocationListener;
import android.location.LocationManager;
import android.net.Uri;
import android.os.AsyncTask;
import android.os.Bundle;
import android.provider.Settings.Secure;
import android.view.Gravity;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;
import android.provider.Settings;

public class testurl extends Activity{
	
	private Button btnSubmit;
	 final String textSource = "http://192.168.43.1:8080/app/opendoor.xhtml";
	@Override
	public void onCreate(Bundle icicle) {
		super.onCreate(icicle);
		setContentView(R.layout.testss);
		
		btnSubmit = (Button)this.findViewById(R.id.button1);
		
		btnSubmit.setOnClickListener(new OnClickListener() {
			public void onClick(View v) {
				
				 new MyTask().execute();
				
			}});
	}

	
	 public class MyTask extends AsyncTask<Void, Void, Void>{
		   
		   String textResult;
		   
		   @Override
		   protected Void doInBackground(Void... params) {
			   
		       URL textUrl;

		       try {
		    	   textUrl = new URL(textSource);

		    	   BufferedReader bufferReader 
		    	   	= new BufferedReader(new InputStreamReader(textUrl.openStream()));
		    	   
		    	   String StringBuffer;
		    	   String stringText = "";
		    	   while ((StringBuffer = bufferReader.readLine()) != null) {
		    		   stringText += StringBuffer;   
		    	   }
		    	   bufferReader.close();

		    	   textResult = stringText;
		       } catch (MalformedURLException e) {
		    	   // TODO Auto-generated catch block
		    	   e.printStackTrace();
		    	   textResult = e.toString();   
		       } catch (IOException e) {
		    	   // TODO Auto-generated catch block
		    	   e.printStackTrace();
		    	   textResult = e.toString();   
		       }

			   return null;
			   
		   }
		   
		   @Override
		   protected void onPostExecute(Void result) {
			   
			  
			   
			   super.onPostExecute(result);   
		   }

	   }
}
